{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5199ae87",
   "metadata": {},
   "outputs": [],
   "source": [
    "from cgai_time.Time import TimeHandler\n",
    "ct = TimeHandler()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d654207c",
   "metadata": {},
   "outputs": [],
   "source": [
    "time_date = ct.strDate2TupleDate('2021-08-12')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "01da209a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2021, 8, 12)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time_date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "1bfed2f5",
   "metadata": {},
   "outputs": [],
   "source": [
    "str_time = ct.tupleDate2StrDate(time_date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ebcb4c4d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021-08-12'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "str_time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "92b1a474",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021-08-12'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ct.getToday()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "baa153fa",
   "metadata": {},
   "outputs": [],
   "source": [
    "start_date = '2021-08-12'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "d9445edd",
   "metadata": {},
   "outputs": [],
   "source": [
    "end_date = '2021-10-01'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "27bdfda0",
   "metadata": {},
   "outputs": [],
   "source": [
    "days = ct.deltaDays(start_date,end_date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "a2296f80",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "50"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "days"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "52254d5e",
   "metadata": {},
   "outputs": [],
   "source": [
    "start_date1 = ct.dateAdd(start_date,50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "a3b2dfd2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021-10-01'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "start_date1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "58f86f40",
   "metadata": {},
   "outputs": [],
   "source": [
    "date_list = ct.getDateList(start_date,end_date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "ea6d38cc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['2021-08-12',\n",
       " '2021-08-13',\n",
       " '2021-08-14',\n",
       " '2021-08-15',\n",
       " '2021-08-16',\n",
       " '2021-08-17',\n",
       " '2021-08-18',\n",
       " '2021-08-19',\n",
       " '2021-08-20',\n",
       " '2021-08-21',\n",
       " '2021-08-22',\n",
       " '2021-08-23',\n",
       " '2021-08-24',\n",
       " '2021-08-25',\n",
       " '2021-08-26',\n",
       " '2021-08-27',\n",
       " '2021-08-28',\n",
       " '2021-08-29',\n",
       " '2021-08-30',\n",
       " '2021-08-31',\n",
       " '2021-09-01',\n",
       " '2021-09-02',\n",
       " '2021-09-03',\n",
       " '2021-09-04',\n",
       " '2021-09-05',\n",
       " '2021-09-06',\n",
       " '2021-09-07',\n",
       " '2021-09-08',\n",
       " '2021-09-09',\n",
       " '2021-09-10',\n",
       " '2021-09-11',\n",
       " '2021-09-12',\n",
       " '2021-09-13',\n",
       " '2021-09-14',\n",
       " '2021-09-15',\n",
       " '2021-09-16',\n",
       " '2021-09-17',\n",
       " '2021-09-18',\n",
       " '2021-09-19',\n",
       " '2021-09-20',\n",
       " '2021-09-21',\n",
       " '2021-09-22',\n",
       " '2021-09-23',\n",
       " '2021-09-24',\n",
       " '2021-09-25',\n",
       " '2021-09-26',\n",
       " '2021-09-27',\n",
       " '2021-09-28',\n",
       " '2021-09-29',\n",
       " '2021-09-30',\n",
       " '2021-10-01']"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "date_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "ab9dca38",
   "metadata": {},
   "outputs": [],
   "source": [
    "r = ct.isLeapyear(2021)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "6e093cac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "4dc8aaaa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ct.isLeapyear(2014)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "b57800dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'周四'"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ct.getWeekdayCName(2021,8,12)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "f0c2c763",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ct.getWeekdayNumber(2021,8,16)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "0012e8ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "start_time, end_time = ct.getCurrentWeekStartAndEnd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "f91a043b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021-08-09'"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "start_time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "290f8b1a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021-08-15'"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "end_time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d4dbb018",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
